import Mock from 'mockjs'
import {param2Obj} from '../utils/myUtils'
let Listbao = []
for(var i=0;i<200;i++){
    Listbao.push({ 
        id: Mock.mock('@id()'),
          fenlei: "课程订单",
          date: Mock.mock('@datetime'),
          name: "幼儿英语课程",
          zhtai: Mock.mock('@integer(0, 1)'),
          money: "2499",
    })
}

export default{
    getAccountData:(config)=>{
        console.log(config);
  let {page,pageSize,search} =  JSON.parse(config.body)
    let newList2 = Listbao.filter(item=>{
        if(search==''){
        return item
        }else if(item.id==search){
            console.log(item.zhtai);
            return item
 
        }else if(item.zhtai==search){
            
            return item
            console.log();
        }
    })
  let newList1 =   newList2.filter((item,index)=>{
            return (page-1) * pageSize <= index && index < page * pageSize
        })
  return{
      code:'200',
      msg:'请求成功',
      data:newList1,
      total:Listbao.length
  }
    },
    
    
    batchDeleteData:(config)=>{
        // let List = []
        let {ids} = JSON.parse(config.body)
     let newlist =  Listbao.filter(item=>{
        console.log(ids);
        console.log(item.id);
            return ids.indexOf(item.id) ===-1
           
        })
        Listbao = newlist
    return{
        code:'200',
        msg:'删除成功',
        data:null

    }
}
}